package _interview75;

import java.util.Stack;

/**
 * 2390. 从字符串中移除星号
 */
public class No2390 {
    public String removeStars(String s) {
        int n = s.length();
        Stack<Character> stack = new Stack<>();
        for (int i = 0; i < n; i++) {
            if (s.charAt(i) == '*') stack.pop();
            else stack.push(s.charAt(i));
        }

        StringBuilder sb = new StringBuilder();
        for (Character c : stack) {
            sb.append(c);
        }

        return sb.toString();
    }
}
